<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
//
//Route::get('/', function () {
//    return view('welcome', ['website' => 'laravel1']);
//})->middleware('token');
//
//Route::get('user/{id}', function ($id) {
//    return 'User ' . $id;
//});

//Route::get('posts/{post}/comments/{comment}', function ($postId, $commendId){
//    return $postId . '-' . $commendId;
//});
//
//Route::get('user/{name?}', function ($name = 'json') {
//    return $name;
//});

//Route::get('user/{name}', function($name){
//    return $name;
//})->where('name', '[A-Za-z]+');

//Route::get('user/{id}', function ($id) {
//
//})->where('id', '[0-9]+');

//Route::get('user/profile', function (){
//    return 'my url:' . route('profile');
//})->name('profile');

Route::get('user/{id}/profile', function ($id) {
    $url = route('profile', ['id' => 1]);
    return $url;
})->name('profile');



Route::get('form_without_csrf_token', function (){
    return '<form method="POST" action="/hello_from_form"><button type="submit">提交</button></form>';
});

Route::get('form_with_csrf_token', function () {
    return '<form method="POST" action="/hello_from_form">' . csrf_field() . '<button type="submit">提交</button></form>';
});

Route::post('hello_from_form', function (){
    return 'hello laravel!';
});

Route::get('user/{id}', 'UserController@show');

Route::resource('posts', 'PostController');

Route::resource('post', 'PostController', ['only' =>
    ['index', 'show']
]);

Route::resource('post', 'PostController', ['except' =>
    ['create', 'store', 'update', 'destroy']
]);

//Route::get('/', function(Request $request){
//});

Route::get('/', function(\Psr\Http\Message\ServerRequestInterface $request){
    dd($request);
});